<?php
/**
 * Created by PhpStorm.
 * User: admin
 * Date: 2016/9/9
 * Time: 15:35
 */
if (!defined('ACCESS')) {
    exit('Access denied.');
}


class AdminBlackList extends Base
{

    private static $table_name = 'black_list';
    // 查询字段
    private static $columns = array(
        'id',
        'user_name',
        'phone',
        'line',
        'email');

    public static function getTableName()
    {
        return self::$table_name;
    }


    public static function replace($data)
    {

        $db = self::__instance();
        if (!is_array($data)) {
            return false;
        }
        $value_str = '';
        $i = 0;
        $sign = ',';
        foreach ($data as $key => $value) {
            $s1 = "'" . $value[0] . "'";
            $s2 = "'" . $value[1] . "'";
            $s3 = "'" . $value[2] . "'";
            $s4 = "'" . $value[3] . "'";
            $i++;
            $value_str_s = '(' . $s1 . ',' . $s2 . ',' . $s3 . ',' . $s4 . ')';
            if ($i == count($data)) {
                $sign = '';
            }
            $value_str .= $value_str_s . $sign;
        }


        $sql = "REPLACE INTO black_list (`user_name`,`phone`,`line`,`email`) VALUES " . $value_str;

        $rt = $db->exec($sql);
        return $rt;
    }
}